<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增消息模板')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-template-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">模板代码：</label>
                <div class="col-sm-8">
                    <input name="templateCode" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">模板名称：</label>
                <div class="col-sm-8">
                    <input name="templateName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">模板内容：</label>
                <div class="col-sm-8">
                    <textarea name="templateContent" class="form-control" required></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">模板类型：</label>
                <div class="col-sm-8">
                    <select name="templateType" class="form-control m-b">
                        <option value="0">系统消息</option>
                        <option value="1" selected>短信消息</option>
                        <option value="2">微信消息</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" name="status" value="0" checked>
                        <label for="status">正常</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" name="status" value="1">
                        <label for="status">停用</label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "business/template";
        $("#form-template-add").validate({
            focusCleanup: true,
            rules: {
                templateCode: {
                    required: true,
                    remote: {
                        url: prefix + "/checkTemplateCodeUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "templateCode": function() {
                                return $.common.trim($("#templateCode").val());
                            }
                        }
                    }
                }
            },
            messages: {
                "templateCode": {
                    remote: "模板代码已经存在"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-template-add').serialize());
            }
        }
    </script>
</body>
</html> 